﻿<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Times New Roman","serif";}
h1
	{mso-style-link:"标题 1 Char";
	margin-right:0cm;
	margin-left:0cm;
	font-size:24.0pt;
	font-family:宋体;}
h2
	{mso-style-link:"标题 2 Char";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:173%;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Cambria","serif";}
h3
	{mso-style-link:"标题 3 Char";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:173%;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Times New Roman","serif";}
p.MsoHeader, li.MsoHeader, div.MsoHeader
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	layout-grid-mode:char;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
p.MsoFooter, li.MsoFooter, div.MsoFooter
	{margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
span.1Char
	{mso-style-name:"标题 1 Char";
	mso-style-link:"标题 1";
	font-family:宋体;
	font-weight:bold;}
span.2Char
	{mso-style-name:"标题 2 Char";
	mso-style-link:"标题 2";
	font-family:"Cambria","serif";
	font-weight:bold;}
span.3Char
	{mso-style-name:"标题 3 Char";
	mso-style-link:"标题 3";
	font-weight:bold;}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body bgcolor=white lang=ZH-CN style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<h1 align=center style='text-align:center'>数组的应用</h1>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>在程序设计中，为了处理方便，把具有相同类型的若干变量按有序的形式组织起来。这些按序排列的同类数据元素的集合称为数组。在Ｃ语言中，数组属于构造数据类型。一个数组可以分解为多个数组元素，这些数组元素可以是基本数据类型或是构造类型。因此按数组元素的类型不同，数组又可分为数值数组、字符数组、指针数组、结构数组等各种类别。本章介绍数值数组和字符数组，其余的在以后各章陆续介绍。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<h2 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:red;border:
none windowtext 1.0pt;padding:0cm'>7.1</span><span style='font-size:12.0pt;
font-family:宋体;color:red;border:none windowtext 1.0pt;padding:0cm'>一维数组的定义和引用</span></span></h2>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle;text-decoration:initial;orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:green;
border:none windowtext 1.0pt;padding:0cm'>7.1.1</span><span style='font-size:
12.0pt;font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>一维数组的定义方式</span></span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>在Ｃ语言中使用数组必须先进行定义。一维数组的定义方式为：类型说明符</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>数组名</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'> [</span><span style='font-family:宋体;color:#555555;background:white'>常量表达式</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>]</span><span style='font-family:宋体;color:#555555;background:white'>；</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>其中：类型说明符是任一种基本数据类型或构造数据类型。数组名是用户定义的数组标识符。方括号中的常量表达式表示数据元素的个数，也称为数组的长度。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int
a[10];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span
style='font-family:宋体;color:#555555;background:white'>说明整型数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>，有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10</span><span style='font-family:宋体;color:#555555;background:white'>个元素。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; float b[10],c[20];&nbsp;&nbsp; </span></span><span
style='font-family:宋体;color:#555555;background:white'>说明实型数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>b</span><span style='font-family:宋体;color:#555555;background:white'>，有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10</span><span style='font-family:宋体;color:#555555;background:white'>个元素，实型数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>c</span><span style='font-family:宋体;color:#555555;background:white'>，有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>20</span><span style='font-family:宋体;color:#555555;background:white'>个元素。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; char
ch[20];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span
style='font-family:宋体;color:#555555;background:white'>说明字符数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ch</span><span style='font-family:宋体;color:#555555;background:white'>，有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>20</span><span style='font-family:宋体;color:#555555;background:white'>个元素。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:blue;border:none windowtext 1.0pt;
padding:0cm;background:white'><span style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>对于数组类型说明应注意以下几点：</span></span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>数组的类型实际上是指数组元素的取值类型。对于同一个数组，其所有元素的数据类型都是相同的。</span></span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>数组名的书写规则应符合标识符的书写规定。</span></span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>数组名不能与其它变量名相同。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int a;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float
a[10];</span></span><br style='text-decoration:initial;orphans: 2;text-align:
start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ……</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>是错误的。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>方括号中常量表达式表示数组元素的个数，如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>a[5]</span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>表示数组</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:green;border:none windowtext 1.0pt;padding:0cm'>a</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'> 5</span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>个元素。但是其下标从</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:green;border:none windowtext 1.0pt;padding:0cm'>0</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>开始计算。因此</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>5</span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>个元素分别为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:green;border:none windowtext 1.0pt;padding:0cm'>a[0],a[1],a[2],a[3],a[4]</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>。</span></span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>5.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>不能在方括号中用变量来表示元素的个数，但是可以是符号常数或常量表达式。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; #define FD 5</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; main()</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
a[3+2],b[7+FD];</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ……</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>是合法的。但是下述说明方式是错误的。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; main()</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int n=5;</span></span><br style='text-decoration:initial;orphans: 2;text-align:
start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int a[n];</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ……</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>6.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>允许在同一个类型说明中，说明多个数组和多个变量。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a,b,c,d,k1[10],k2[20];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:green;
border:none windowtext 1.0pt;padding:0cm'>7.1.2</span><span style='font-size:
12.0pt;font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>一维数组元素的引用</span></span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>数组元素是组成数组的基本单元。数组元素也是一种变量，</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>其标识方法为数组名后跟一个下标。下标表示了元素在数组中的顺序号。数组元素的一般形式为：数组名</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>[</span><span style='font-family:宋体;color:#555555;background:white'>下标</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>]</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br style='text-decoration:initial;orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>其中下标只能为整型常量或整型表达式。如为小数时，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>C</span><span style='font-family:宋体;color:#555555;background:white'>编译将自动取整。例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>a[5]</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>a[i+j]</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>a[i++]</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>都是合法的数组元素。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>数组元素通常也称为下标变量。必须先定义数组，才能使用下标变量。在Ｃ语言中只能逐个地使用下标变量，而不能一次引用整个数组。例如，输出有</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10</span><span style='font-family:宋体;color:#555555;background:white'>个元素的数组必须使用循环语句逐个输出各下标变量：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; for(i=0; i&lt;10; i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
printf(&quot;%d&quot;,a[i]);</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>而不能用一个语句输出整个数组。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>下面的写法是错误的：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>printf(&quot;%d&quot;,a);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>7.1</span><span style='font-family:宋体;color:#555555;background:white'>】</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>{</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; int i,a[10];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;=9;i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i]=i;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=9;i&gt;=0;i--)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;%d
&quot;,a[i]);</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;</span></span></span><span lang=EN-US><a
href="http://www.tjac.edu.cn/teacher/jinrunzhao/example/EX7_1.EXE"
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'><span class=apple-converted-space><span style='font-family:"Tahoma","sans-serif";
color:blue;border:none windowtext 1.0pt;padding:0cm;background:white'>&nbsp;</span></span><span
style='font-family:"Tahoma","sans-serif";color:blue;border:none windowtext 1.0pt;
padding:0cm;background:white;text-decoration:none'><img border=0 width=32
height=32 src="7.files/image001.png" style='text-decoration:initial;border-bottom-width:
0px;border-left-width:0px;border-right-width:0px;border-top-width:0px;
font-size:14px;list-style-type:none;margin-bottom:0px;margin-left:0px;
margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:
0px;padding-top:0px'></span></a></span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>7.2</span><span style='font-family:宋体;color:#555555;background:white'>】</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>{</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; int i,a[10];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;10;)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i++]=i;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=9;i&gt;=0;i--)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
printf(&quot;%d&quot;,a[i]);</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;}</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;</span></span></span><span lang=EN-US><a
href="http://www.tjac.edu.cn/teacher/jinrunzhao/example/EX7_2.EXE"
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'><span class=apple-converted-space><span style='font-family:"Tahoma","sans-serif";
color:blue;border:none windowtext 1.0pt;padding:0cm;background:white'>&nbsp;</span></span><span
style='font-family:"Tahoma","sans-serif";color:blue;border:none windowtext 1.0pt;
padding:0cm;background:white;text-decoration:none'><img border=0 width=32
height=32 src="7.files/image001.png" style='text-decoration:initial;border-bottom-width:
0px;border-left-width:0px;border-right-width:0px;border-top-width:0px;
font-size:14px;list-style-type:none;margin-bottom:0px;margin-left:0px;
margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:
0px;padding-top:0px'></span></a></span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>7.3</span><span style='font-family:宋体;color:#555555;background:white'>】</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>{</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; int i,a[10];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;10;)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i++]=2*i+1;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;=9;i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>printf(&quot;%d &quot;,a[i]);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; printf(&quot;\n%d %d\n&quot;,a[5.2],a[5.8]);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp; </span></span><span style='font-family:
宋体;color:#555555;background:white'>本例中用一个循环语句给</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>a</span><span
style='font-family:宋体;color:#555555;background:white'>数组各元素送入奇数值，然后用第二个循环语句输出各个奇数。在第一个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'> for</span><span style='font-family:宋体;color:#555555;background:white'>语句中，表达式</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3</span><span style='font-family:宋体;color:#555555;background:white'>省略了。在下标变量中使用了表达式</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i++</span><span style='font-family:宋体;color:#555555;background:white'>，用以修改循环变量。当然第二个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>语句也可以这样作，Ｃ语言允许用表达式表示下标。程序中最后一个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>printf</span><span style='font-family:宋体;color:#555555;background:white'>语句输出了两次</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[5]</span><span style='font-family:宋体;color:#555555;background:white'>的值，可以看出当下标不为整数时将自动取整。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:green;
border:none windowtext 1.0pt;padding:0cm'>7.1.3</span><span style='font-size:
12.0pt;font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>一维数组的初始化</span></span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'><span style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>给数组赋值的方法除了用赋值语句对数组元素逐个赋值外，</span><span style='font-family:
"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;padding:0cm;
background:white'> </span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'>还可采用初始化赋值和动态赋值的方法。</span></span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>数组初始化赋值是指在数组定义时给数组元素赋予初值。数组初始化是在编译阶段进行的。这样将减少运行时间，提高效率。初始化赋值的一般形式为：类型说明符</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>数组名</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>[</span><span style='font-family:宋体;color:#555555;background:white'>常量表达式</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>]={</span><span style='font-family:宋体;color:#555555;background:white'>值，值</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>……</span><span style='font-family:宋体;color:#555555;background:white'>值</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>}</span><span style='font-family:宋体;color:#555555;background:white'>；</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>其中在</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>{ }</span><span style='font-family:宋体;color:#555555;background:white'>中的各数据值即为各元素的初值，各值之间用逗号间隔。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[10]={ 0,1,2,3,4,5,6,7,8,9
};</span></span><br style='text-decoration:initial;orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>相当于</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; &nbsp; a[0]=0;a[1]=1...a[9]=9;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:blue;border:none windowtext 1.0pt;
padding:0cm;background:white'><span style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>Ｃ语言对数组的初始化赋值还有以下几点规定：</span></span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>可以只给部分元素赋初值。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>当</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>{ }</span><span style='font-family:宋体;color:#555555;background:white'>中值的个数少于元素个数时，只</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>给前面部分元素赋值。例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[10]={0,1,2,3,4};</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>表示只给</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[0]</span><span style='font-family:宋体;color:#555555;background:white'>～</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[4]5</span><span style='font-family:宋体;color:#555555;background:white'>个元素赋值，而后</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>5</span><span style='font-family:宋体;color:#555555;background:white'>个元素自动赋</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0</span><span style='font-family:宋体;color:#555555;background:white'>值。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>只能给元素逐个赋值，不能给数组整体赋值。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如给十个元素全部赋</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1</span><span style='font-family:宋体;color:#555555;background:white'>值，只能写为：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[10]={1,1,1,1,1,1,1,1,1,1};</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>而不能写为：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[10]=1;</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'><span style='text-decoration:initial'>如给全部元素赋值，则在数组说明中，可以不给出数组元素的个数。</span></span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>例如：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[5]={1,2,3,4,5};</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>可写为：</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; int a[]={1,2,3,4,5};</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span style='text-decoration:initial'><span lang=EN-US
style='font-size:12.0pt;font-family:"Tahoma","sans-serif";color:green;
border:none windowtext 1.0pt;padding:0cm'>7.1.4</span><span style='font-size:
12.0pt;font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>一维数组程序举例</span></span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>可以在程序执行过程中，对数组作动态赋值。这时可用循环语句配合</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>scanf</span><span style='font-family:宋体;color:#555555;background:white'>函数逐个对数组元素赋值。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>7.4</span><span style='font-family:宋体;color:#555555;background:white'>】</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>{</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; int i,max,a[10];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; printf(&quot;input 10 numbers:\n&quot;);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;10;i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
scanf(&quot;%d&quot;,&amp;a[i]);</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; max=a[0];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=1;i&lt;10;i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(a[i]&gt;max)
max=a[i];</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; printf(&quot;maxmum=%d\n&quot;,max);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; </span></span><span
style='font-family:宋体;color:#555555;background:white'>本例程序中第一个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>语句逐个输入</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10</span><span style='font-family:宋体;color:#555555;background:white'>个数到数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>中。</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>然后把</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[0]</span><span style='font-family:宋体;color:#555555;background:white'>送入</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>中。在第二个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>语句中，从</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[1]</span><span style='font-family:宋体;color:#555555;background:white'>到</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[9]</span><span style='font-family:宋体;color:#555555;background:white'>逐个与</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>中的内容比较，若比</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>的值大，则把该下标变量送入</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>中，因此</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>总是在已比较过的下标变量中为最大者。比较结束，输出</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>max</span><span style='font-family:宋体;color:#555555;background:white'>的值。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>7.5</span><span style='font-family:宋体;color:#555555;background:white'>】</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>main()</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>{</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; int i,j,p,q,s,a[10];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; printf(&quot;\n input 10 numbers:\n&quot;);</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;10;i++)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
scanf(&quot;%d&quot;,&amp;a[i]);</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; for(i=0;i&lt;10;i++){</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p=i;q=a[i];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for(j=i+1;j&lt;10;j++)</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp; &nbsp; if(q&lt;a[j]) {
p=j;q=a[j]; }</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(i!=p)</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {s=a[i];</span></span><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
a[i]=a[p];</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
a[p]=s; }</span></span><br style='text-decoration:initial;orphans: 2;
text-align:start;widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
printf(&quot;%d&quot;,a[i]);</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>&nbsp; }</span></span><br style='text-decoration:
initial;orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>}</span></span><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span lang=EN-US><a
href="http://www.tjac.edu.cn/teacher/jinrunzhao/example/EX7_5.EXE"
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'><span style='font-family:"Tahoma","sans-serif";color:blue;border:none windowtext 1.0pt;
padding:0cm;background:white;text-decoration:none'><img border=0 width=32
height=32 src="7.files/image001.png" style='text-decoration:initial;border-bottom-width:
0px;border-left-width:0px;border-right-width:0px;border-top-width:0px;
font-size:14px;list-style-type:none;margin-bottom:0px;margin-left:0px;
margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:
0px;padding-top:0px'></span></a></span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br style='text-decoration:initial;
orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;word-spacing:0px'>
</span><span style='font-family:宋体;color:#555555;background:white'><span
style='orphans: 2;text-align:start;widows: 2;-webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;float:none;word-spacing:0px'>本例程序中用了两个并列的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>循环语句，在第二个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for </span><span style='font-family:宋体;color:#555555;background:white'>语句中又嵌套了一个循环语句。第一个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>语句用于输入</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10</span><span style='font-family:宋体;color:#555555;background:white'>个元素的初值。第二个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>for</span><span style='font-family:宋体;color:#555555;background:white'>语句用于排序。本程序的排序采用逐个比较的方法进行。在</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i</span><span style='font-family:宋体;color:#555555;background:white'>次循环时，把第一个元素的下标</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i</span><span style='font-family:宋体;color:#555555;background:white'>赋于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>p</span><span style='font-family:宋体;color:#555555;background:white'>，而把该下标变量值</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i]</span><span style='font-family:宋体;color:#555555;background:white'>赋于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>q</span><span style='font-family:宋体;color:#555555;background:white'>。然后进入小循环，从</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i+1]</span><span style='font-family:宋体;color:#555555;background:white'>起到最后一个元素止逐个与</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i]</span><span style='font-family:宋体;color:#555555;background:white'>作比较，有比</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i]</span><span style='font-family:宋体;color:#555555;background:white'>大者则将其下标送</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>p</span><span style='font-family:宋体;color:#555555;background:white'>，元素值送</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>q</span><span style='font-family:宋体;color:#555555;background:white'>。一次循环结束后，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>p</span><span style='font-family:宋体;color:#555555;background:white'>即为最大元素的下标，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>q</span><span style='font-family:宋体;color:#555555;background:white'>则为该元素值。若此时</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i≠p</span><span style='font-family:宋体;color:#555555;background:white'>，说明</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>p,q</span><span style='font-family:宋体;color:#555555;background:white'>值均已不是进入小循环之前所赋之值，则交换</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i]</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[p]</span><span style='font-family:宋体;color:#555555;background:white'>之值。</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>此时</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a[i]</span><span style='font-family:宋体;color:#555555;background:white'>为已排序完毕的元素。输出该值之后转入下一次循环。对</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i+1</span><span style='font-family:宋体;color:#555555;background:white'>以后各个元素排序。</span></span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&nbsp;</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>数组是程序设计中最常用的数据结构。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<br style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>1</span></span><span style='font-family:宋体;
color:#555555;background:white'>、数组可分为数值数组</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>(</span><span
style='font-family:宋体;color:#555555;background:white'>整数组，实数组</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>，字符数组以及后面将要介绍的指针数组，结构数组等。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>2</span></span><span style='font-family:宋体;
color:#555555;background:white'>、数组可以是一维的，二维的或多维的。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>3</span></span><span style='font-family:宋体;
color:#555555;background:white'>、数组类型说明由类型说明符、数组名、数组长度</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>(</span><span
style='font-family:宋体;color:#555555;background:white'>数组元素个数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>三部分组成。数组元素又称为下标变量。</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>数组的类型是指下标变量取值的类型。</span></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br
style='text-decoration:initial;orphans: 2;text-align:start;widows: 2;
-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:
0px'>
<span style='background:white'><span style='orphans: 2;text-align:start;
widows: 2;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;
float:none;word-spacing:0px'>4</span></span><span style='font-family:宋体;
color:#555555;background:white'>、对数组的赋值可以用数组初始化赋值，输入函数动态赋值和赋值语句赋值三种方法实现。对数值数组不能用赋值语句整体赋值、输入或输出，而必须用循环语句逐个对数组元素进行操作。</span></span></p>

</div>

</body>

</html>
